home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_08 / phillip2 / maincp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-25  |  2.2 KB  |  100 lines

  1.  
  2.     /***********************************************
  3.     *
  4.     *    file d:\cips\maincp.c
  5.     *
  6.     *    Functions: This file contains
  7.     *       main
  8.     *
  9.     *    Purpose:
  10.     *       This file contains the main calling
  11.     *       routine for a program which 
  12.     *       cuts a piece from one image and pastes
  13.     *       it into another.
  14.     *
  15.     *    External Calls:
  16.     *       cutp.c - cut_image_piece
  17.     *                paste_image_piece
  18.     *       gpcips.c - my_clear_text_screen
  19.     *
  20.     *    Modifications:
  21.     *       8 April 1992 - created
  22.     *
  23.     *************************************************/
  24.  
  25. #include "cips.h"
  26.  
  27.  
  28.  
  29. short the_image[ROWS][COLS];
  30. short out_image[ROWS][COLS];
  31.  
  32. main(argc, argv)
  33.    int  argc;
  34.    char *argv[];
  35. {
  36.  
  37.    char     name[80], name2[80];
  38.    int      il1, ie1, ll1, le1,
  39.             il2, ie2, ll2, le2;
  40.  
  41.    my_clear_text_screen();
  42.  
  43.        /******************************************
  44.        *
  45.        *  Interpret the command line parameters.
  46.        *
  47.        *******************************************/
  48.  
  49.    if(argc < 3 || argc > 7){
  50.     printf(
  51.      "\n"
  52.      "\n usage: maincp in-file out_file "
  53.      "[in-il in-ie out-il out-ie]"
  54.      "\n"
  55.      "\n If you do not specify the il's ie's, "
  56.      "they are set to 1."
  57.      "\n The le's le's equal il+ROWS ie+COLS."
  58.      "\n");
  59.     exit(0);
  60.    }
  61.  
  62.    strcpy(name, argv[1]);
  63.    strcpy(name2, argv[2]);
  64.  
  65.    if(argc > 3 || argc <= 7){
  66.       il1 = atoi(argv[3]);
  67.       ie1 = atoi(argv[4]);
  68.       il2 = atoi(argv[5]);
  69.       ie2 = atoi(argv[6]);
  70.    }
  71.    else{
  72.       il1 = 1;
  73.       ie1 = 1;
  74.       il2 = 1;
  75.       ie2 = 1;
  76.    }
  77.  
  78.    ll1 = il1 + ROWS;
  79.    le1 = ie1 + COLS;
  80.    ll2 = il2 + ROWS;
  81.    le2 = ie2 + COLS;
  82.  
  83.    create_file_if_needed(name, name2, out_image);
  84.  
  85.        /*************************
  86.        *
  87.        *   Cut and paste
  88.        *
  89.        **************************/
  90.  
  91.    printf("\nin  file il=%d ie=%d ll=%d le=%d",
  92.           il1, ie1, ll1, le1);
  93.    printf("\nout file il=%d ie=%d ll=%d le=%d",
  94.           il2, ie2, ll2, le2);
  95.    cut_image_piece(name, the_image, il1, ie1, ll1, le1);
  96.    paste_image_piece(name2, name, the_image, out_image, 
  97.                      il2, ie2, ll2, le2);
  98.  
  99. }  /* ends main */
  100.